<template>
  <div id="app">
    <easy-top-vue></easy-top-vue>
    <heard v-if="isShow"></heard>
    <category-nav v-if="isShow" :categories1="categories1" :isHidden="isHidden" ></category-nav>
    <router-view></router-view>
    <easy-footer-vue></easy-footer-vue>
  </div>
</template>

<script>
import EasyFooterVue from './components/EasyFooter.vue'
import CategoryNav from './components/easyfront/CategoryNav.vue';
import Heard from './components/easyfront/Heard.vue';
import EasyTopVue from './components/EasyTop.vue'

export default {
  name: 'App',
  components: {
    EasyFooterVue,
    EasyTopVue,
    Heard,
    CategoryNav
  },
  mounted(){
    this.getCategoryByPId(0);//获取首页一级分类信息
  },
  computed:{
    isHidden:function(){
      let path = this.$route.path;
      let arr = ['/goodslist','/detail',"/cart-one","/cart-two","/cart-three"];
      if(arr.indexOf(path)!=-1){
        return true;
      }else{
        return false;
      }
    },
    isShow:function(){
      let path = this.$route.path;
      let arr = ['/front-index','/goodslist','/detail',"/cart-one","/cart-two","/cart-three"];
      if(arr.indexOf(path)!=-1){
        return true;
      }else{
        return false;
      }
    }
  },
  data:function(){
    return{
      categories1:[],
    }
  },
  methods:{
      //获取首页一级分类信息
        getCategoryByPId(parentId){
            this.$axios({
                url:'/easybuy/category/'+parentId
            }).then(rs=>{
                console.log(rs);
                this.categories1 = rs.data.categoryList;
            })
        },
  }
}
</script>

<style>

</style>
